package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.service.TestService;
import com.atguigu.tingshu.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: atguigu
 * @create: 2024-12-04 14:02
 */
@Slf4j
@RestController
@RequestMapping("/api/album/test")
public class TestController {


    @Autowired
    private TestService testService;

    @GetMapping("/getData/{id}")
    public String testCache(@PathVariable Long id) {
        String data = testService.getData(id);
        return data;
    }

    @PutMapping("/updateData/{id}")
    public String updateData(@PathVariable Long id) {
        testService.updateData(id);
        return "更新成功";
    }



    @GetMapping("/read/{id}")
    public Result<String> read(@PathVariable Long id) {
        String str = testService.read(id);
        return Result.ok(str);
    }



    @GetMapping("/write/{id}")
    public Result write(@PathVariable Long id) {
        testService.write(id);
        return Result.ok();
    }

}
